import { CommonModule } from '@angular/common';
import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core';
import { Observable } from 'rxjs';
import { increment, decrement, reset } from '@app/store/counter.actions';
import { Store } from '@ngrx/store';
import { NzButtonComponent } from 'ng-zorro-antd/button';
import { NzBadgeComponent } from 'ng-zorro-antd/badge';

@Component({
  selector: 'app-welcome',
  standalone: true,
  imports: [CommonModule,NzButtonComponent,NzBadgeComponent],
  templateUrl: './welcome.component.html',
  styleUrls: ['./welcome.component.less'],
})
export class WelcomeComponent {
  count$: Observable<number>;

  // @ViewChild('count', {static: true,}) count!: TemplateRef<void>;

  constructor(private store: Store<{ count: number }>) {
    this.count$ = store.select('count');
  }

  increment() {
    this.store.dispatch(increment());
  }

  decrement() {
    this.store.dispatch(decrement());
  }

  reset() {
    this.store.dispatch(reset());
  }
}
